import React, { useEffect, useState } from "react";
import { Modal } from "antd";
import Form from "../TopForm";
import { getPageSourceInfo } from "../../../../shared/util";

const FormModal = React.memo((props: any) => {
    console.log(props);
    const { origin } = getPageSourceInfo();
    const { showFormModal, onHide, setShowFooter, setShowSuccessModal, setQrUrl } = props;
    const [showModal, setShowModal] = useState(false);
    useEffect(() => {
        setShowModal(showFormModal)
        if (showFormModal) {
            if ((window as any) && (window as any).goldlog) {
                (window as any).goldlog.record(
                    "/sc.supplier.newsign",
                    "EXP",
                    `btn=leads_form_exp&origin=${origin}`,
                    "GET"
                );
            }
        }
    }, [showFormModal])
    return (
        <Modal
            className="form-modal"
            open={showModal}
            okButtonProps={{}}
            cancelButtonProps={{}}
            onCancel={() => {
                setShowModal(false)
                onHide && onHide()
            }}
        >
            <Form 
                formName="formModal" 
                extText={"您希望了解以下哪些服务"} 
                setShowFooter={setShowFooter} 
                setQrUrl={setQrUrl}
                setShowSuccessModal={setShowSuccessModal}
                onHide={() => {
                    setShowModal(false)
                    onHide && onHide()
                }}>
            </Form>
        </Modal>
    )
});

export default FormModal;